//
//  UIViewController+UIExtension.m
//  M-Saler
//
//  Created by Teresa on 2020/5/21.
//  Copyright © 2020 Teresa. All rights reserved.
//

#import "UIViewController+UIExtension.h"

@implementation UIViewController (UIExtension)

//红底白字
-(void)configNavBarRed{
    [self.navigationController.navigationBar navBarBackGroundColor:MH_Red_Color image:nil isOpaque:YES];
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor]};
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"NavBack_White"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
                                                                style:UIBarButtonItemStylePlain target:self action:@selector(backbtnDefaultAction)];
    [self.navigationItem setLeftBarButtonItem:backItem];

}
//白底黑字
-(void)configNavBarWhite{
    [self.navigationController.navigationBar navBarBackGroundColor:[UIColor whiteColor] image:nil isOpaque:NO];
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor darkTextColor]};

    UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@"NavBack_Black"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
                                                                style:UIBarButtonItemStylePlain target:self action:@selector(backbtnDefaultAction)];
    [self.navigationItem setLeftBarButtonItem:backItem];
}

-(void)translucentNavBar:(BOOL)isTranslucent{
    if (isTranslucent) {
        [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
        self.navigationController.navigationBar.translucent = YES;
        [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    }else{
        
    }
}

-(void)backbtnDefaultAction{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
